using MediatR;
using B.S.XZYData.ErrorCode;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace B.S.XZYData.Api.Wrter.Application.Command.AssemblyWorkOrder
{
    /// <summary>
    /// 修改装配工单命令
    /// </summary>
    public class UpdateAssemblyWorkOrderCommand : IRequest<ApiResult<bool>>
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [Required(ErrorMessage = "装配工单ID不能为空")]
        public long Id { get; set; }

        /// <summary>
        /// 单据编号
        /// </summary>
        [Required(ErrorMessage = "单据编号不能为空")]
        public string DocumentNumber { get; set; } = string.Empty;

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        [Required(ErrorMessage = "修改人不能为空")]
        public string Updator { get; set; } = string.Empty;

        /// <summary>
        /// 产品明细列表
        /// </summary>
        [Required(ErrorMessage = "产品明细不能为空")]
        public List<UpdateProductDetailDto> ProductDetails { get; set; } = new List<UpdateProductDetailDto>();
    }

    /// <summary>
    /// 修改产品明细DTO
    /// </summary>
    public class UpdateProductDetailDto
    {
        /// <summary>
        /// 主键ID（新增时为null，修改时提供）
        /// </summary>
        public long? Id { get; set; }

        /// <summary>
        /// 层级编号
        /// </summary>
        [Required(ErrorMessage = "层级编号不能为空")]
        public string HierarchyNumber { get; set; } = string.Empty;

        /// <summary>
        /// 产品编号
        /// </summary>
        [Required(ErrorMessage = "产品编号不能为空")]
        public string ProductNumber { get; set; } = string.Empty;

        /// <summary>
        /// 产品名称
        /// </summary>
        [Required(ErrorMessage = "产品名称不能为空")]
        public string ProductName { get; set; } = string.Empty;

        /// <summary>
        /// 产品规格
        /// </summary>
        public string? ProductSpecification { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string? WorkOrderDetailNumber { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        [Required(ErrorMessage = "数量不能为空")]
        [Range(1, int.MaxValue, ErrorMessage = "数量必须大于0")]
        public int Quantity { get; set; }

        /// <summary>
        /// 完成数
        /// </summary>
        public int? CompletedQuantity { get; set; } = 0;
    }
} 